﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    x:Class="CodeBadger.GasMileage.Views.ListPage"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">
	
    <phone:PhoneApplicationPage.Resources>
		<DataTemplate x:Key="NotebookItemTemplate">
			<StackPanel Width="460" Margin="10,0">
                    <Grid Margin="0,20,0,0">
                        <TextBlock x:Name="DateTextBlock" 
                                   Text="{Binding Date, ConverterParameter=d, Converter={StaticResource DateTimeConverter}}" 
                                   HorizontalAlignment="Left" 
                                   Foreground="{StaticResource PhoneForegroundBrush}" 
                                   FontSize="30" FontWeight="Bold"/>
                        <TextBlock x:Name="MilesPerGallonTextBlock" 
                                   Text="{Binding MilesPerGallon, ConverterParameter=\{0:###.#\} MPG, 
                                        Converter={StaticResource TextFormatConverter}}" 
                                   HorizontalAlignment="Right" 
                                   Foreground="{StaticResource PhoneAccentBrush}" 
                                   FontSize="30" FontWeight="Bold"/>
                    </Grid>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <TextBlock x:Name="PriceTextBlock" Grid.Column="0" 
                                   Text="{Binding Price, ConverterParameter=\{0:C\}, 
                                        Converter={StaticResource TextFormatConverter}}" 
                                   Visibility="{Binding PriceRecorded, 
                                        Converter={StaticResource VisibilityConverter}}"
                                   Foreground="{StaticResource PhoneForegroundBrush}" FontSize="26"/>
                        <TextBlock x:Name="GallonsTextBlock" Grid.Column="1"
                                   Text="{Binding Gallons, ConverterParameter=\{0:###.##\} Gallons, 
                                        Converter={StaticResource TextFormatConverter}}" 
                                   Foreground="{StaticResource PhoneForegroundBrush}" FontSize="26"/>
                        <TextBlock x:Name="MileageTextBlock" Grid.Column="2" 
                                   Text="{Binding Mileage, ConverterParameter=\{0:####.##\} Miles, 
                                        Converter={StaticResource TextFormatConverter}}" 
                                   Foreground="{StaticResource PhoneForegroundBrush}" 
                                   HorizontalAlignment="Right" FontSize="26"/>
                    </Grid>				
			</StackPanel>
		</DataTemplate>
	</phone:PhoneApplicationPage.Resources>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsMenuEnabled="False" >
            <shell:ApplicationBar.Buttons>
                <shell:ApplicationBarIconButton IconUri="/Icons/AddIcon.png" 
                                                Text="Add" Click="AddClick"/>
                <shell:ApplicationBarIconButton IconUri="/Icons/EmailIcon.png"
                                                Text="Email" Click="EmailClick"/>                
            </shell:ApplicationBar.Buttons>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

    <Grid x:Name="LayoutRoot" Background="Transparent" 
          d:DataContext="{Binding Source={StaticResource NotebookSampleData}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12">
            <TextBlock x:Name="ApplicationTitle" Text="GAS MILEAGE" 
                       Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="notebook" Margin="-3,-8,0,0" 
                       Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentGrid" Grid.Row="1">
            <ListBox Background="Transparent"
			         ItemTemplate="{StaticResource NotebookItemTemplate}" 
                     ItemsSource="{Binding Entries}" 
                     SelectionChanged="ListBoxSelectionChanged" />
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>
